// 封装和医院列表数据相关的函数
import { request } from '@utils/http'
import {
  IhospitalListParams,
  IhospitalListRes,
  IprovinceList,
  IhospitalShow,
  Status,
  IdepList,
  IScheduleRuleRes,
  IscheduleList,
} from './model/hospitalListTypes'
// 获取医院列表数据的函数
export function reqGetHospitalList({
  page,
  pageSize,
  hosname,
  hoscode,
  hostype,
  provinceCode,
  cityCode,
  districtCode,
  status,
}: IhospitalListParams) {
  return request.get<any, IhospitalListRes>(
    `/admin/hosp/hospital/${page}/${pageSize}`,
    {
      params: {
        hosname,
        hoscode,
        hostype,
        provinceCode,
        cityCode,
        districtCode,
        status,
      },
    }
  )
}

// 获取省级数据的接口

export function reqGetProvinceList(province: string = 'province') {
  return request.get<any, IprovinceList>(
    `/admin/cmn/dict/findByDictCode/${province}`
  )
}

// 获取市或区数据的接口
export function reqGetCityOrDistrictList(parentId: string) {
  return request.get<any, IprovinceList>(
    `/admin/cmn/dict/findByParentId/${parentId}`
  )
}

// 获取医院详情的接口

export function reqGetHospitalShow(id: string) {
  return request.get<any, IhospitalShow>(`/admin/hosp/hospital/show/${id}`)
}

// 修改医院状态接口
export function reqUpdateHospitalStatus(id: string, status: Status) {
  return request.get<any, null>(
    `/admin/hosp/hospital/updateStatus/${id}/${status}`
  )
}

// 获取所有科室数据的接口
export function reqGetDeps(hoscode: string) {
  return request.get<any, IdepList>(`/admin/hosp/department/${hoscode}`)
}

// 获取排班规则的忌口
export function reqGetScheduleRules(
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) {
  return request.get<any, IScheduleRuleRes>(
    `/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  )
}

// 获取排班详情列表
export function reqGetScheduleList(
  hoscode: string,
  depcode: string,
  workDate: string
) {
  return request.get<any, IscheduleList>(
    `/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`
  )
}
